from __future__ import absolute_import

import os
from datetime import timedelta
from django.conf import settings  # noqa
from celery.schedules import crontab
from celery import Celery

app = Celery('esr', backend=settings.BACKEND_URL, broker=settings.BROKER_URL)

CELERY_ROUTES = {
}


CELERYBEAT_SCHEDULE = {}
app.conf.update(CELERYBEAT_SCHEDULE=CELERYBEAT_SCHEDULE)
app.conf.update(CELERY_ROUTES=CELERY_ROUTES)
app.conf.update(CELERY_ALWAYS_EAGER=getattr(settings, "CELERY_ALWAYS_EAGER", False))
app.conf.update(CELERYD_PREFETCH_MULTIPLIER=1)
# load task modules from all registered Django app configs.
app.autodiscover_tasks(['Task', 'esr_parser'])


@app.task(bind=True)
def debug_task(self):
    print('request: {0!r}'.format(self.request))


@app.task
def add_task(x, y):
    print(x + y)
